Introduce A2UI Express package and express_chat example application#932
Draft
gspencergoog wants to merge 23 commits into
Draft
Introduce A2UI Express package and express_chat example application#932gspencergoog wants to merge 23 commits into
express_chat example application#932gspencergoog wants to merge 23 commits into
Conversation
- Implement direct data path assignments compiler parsing and evaluation - Structuredly accumulate deep nested path maps and include in returned envelope - Extract and sequentially emit dataModel as an UpdateDataModel message - Support <a2ui> and </a2ui> sentinel tags for robust, leak-free layout extraction - Statefully filter DSL lines in real-time streaming chat bubble streams - Support format-spanning multi-line statements in compiler parsers - Rethrow programming Error types in handleMessage to prevent LLM debugging loops - Add comprehensive multi-line and path assignment unit tests
…piler, prompt builder, and local Genkit models - Create packages/genui_express as a shareable Flutter plugin package. - Port A2UI Express lexer, token scanner, parser, and catalog schema helper. - Implement ExpressPromptBuilder extending GenUI's PromptBuilder with compact signature contracts optimized for on-device LLMs. - Develop GenuiExpressLocalModels registering Apple Intelligence (FoundationModels), Android AI Edge (Gemini Nano), and Ollama HTTP completions directly with Genkit. - Expose ExpressLocalTransport implementing the core Transport interface to coordinate local streaming and compilation pipelines. - Add comprehensive compiler parser and transport streaming tests.
…enui_express package - Delete local hand-rolled express compiler, transport, and custom agent loop files inside examples/express_chat. - Update express_chat/pubspec.yaml to depend on genui_express and genkit. - Refactor ChatSession and ChatScreen widgets to accept Genkit engine and ModelRef parameters in place of custom AiClient. - Convert TextOnlyChatSession and A2uiChatSession to coordinate via ExpressLocalTransport and Genkit. - Rewrite integration test and fake client to instantiate Genkit models and verify layouts using A2uiMessage subtype pattern casts. - Verify standard A2UI JSON array envelope resolution under Postel's Law in ExpressLocalTransport. - Confirm that all smoke and integration tests pass successfully.
…nfigurable - Update local/http-completion model to read baseUrl and model from Genkit request configuration map. - Change default completions endpoint to http://localhost:8080/v1 and model name to mlx-community/gemma-4-e2b-it-4bit, matching the monorepo local MLX server.
…ple Intelligence on-device LLM - Connect genui_express MethodChannel and EventChannel handlers to Swift on macOS and iOS. - Use NaturalLanguage.LanguageModelSession to stream hardware-accelerated response chunks. - Support checkAvailability call and handle asynchronous task cancellation.
…enforce compile-safe LanguageModeling imports - Override MACOSX_DEPLOYMENT_TARGET to 15.0 for all native targets inside CocoaPods post_install block in examples/express_chat/macos/Podfile. - Increase minimum platform versions to macOS 15.0 and iOS 18.0 in all package podspecs and SPM Package manifests. - Integrate #if canImport(LanguageModeling) conditional compilation block inside native Apple plugins to bypass module resolution errors on simulated/sandboxed build servers. - Update examples/express_chat to default to local/apple-foundation-models session in chat_session.dart.
…ons for gMac compatibility - Default A2uiChatSession and TextOnlyChatSession model reference to local/http-completion in chat_session.dart. - Remove unused package:genkit/src/core/action.dart import. - Simplify stream variable definition with type inference.
…ndation-models - Set default model reference back to local/apple-foundation-models in chat_session.dart for production open-source Apple Silicon Neural Engine deployment. - Keep dynamic local/http-completion completions model active for local gMac completions testing.
…ocal developer testing - Default A2uiChatSession and TextOnlyChatSession model reference back to local/http-completion in chat_session.dart, enabling plug-and-play local gMac completions. - Keep Swift plugins clean and Sequoia-compliant.
…conditional imports for Chrome built-in AI - Add genkit_chrome dependency to packages/genui_express. - Implement on_device_plugins_stub.dart and on_device_plugins_web.dart to isolate web-only js_interop imports. - Conditionally register ChromeAIPlugin on Genkit when compiling for web. - Use kIsWeb in examples/express_chat to dynamically default to 'chrome/gemini-nano' on Chrome and 'local/http-completion' on native platforms.
…ore required web plugin registrant - Restore required packages/genui_express/lib/genui_express_web.dart to resolve web compilation entrypoint registrant error. - Remove package genkit_chrome from packages/genui_express dependencies and add it to examples/express_chat dependencies. - Implement chrome_plugin_stub.dart and chrome_plugin_web.dart in examples/express_chat using package:genkit/plugin.dart. - Pass getPlatformPlugins() conditionally to the Genkit constructor list inside chat_session.dart. - Clean up packages/genui_express plugin stubs.
express_chat example application
…nd genui_express - Add mounted checks before and inside postFrameCallback in main.dart to avoid disposed ScrollController crashes. - Correct integration test README path reference to express_chat. - Remove list allocation overhead in messages getter, and specify return Stream types. - Implement dynamic type safety checks on climbing location identifiers. - Replace assert checks with runtime nullable checks for SurfaceHost, using local variable promotion.
…xample - Exclude web-only files (*_web.dart) from ephemeral coverage test generation in test_and_fix.dart to prevent VM compilation errors. - Replace genui_express/README.md with a detailed package description, usage instructions, and a concrete implementation code sample.
a2b980f to
ee5c186
Compare
…c variables - Resolved all Dart analyzer warnings, style/info violations, and line length issues. - Replaced generic 'dynamic' references with 'Object?' in model reference, generateStream API, and A2UI layout DSL JSON maps. - Added explicit generic type arguments to raw 'List' and 'Map' type checks and casts. - Formatted all modified files and confirmed everything compiles cleanly and passes all unit and integration tests.
…odel constants - Restricted public library exports in `genui_express.dart` to strictly keep tokenizer, parsing, and schema helper internals hidden. - Defined public static const string references for local model names (`appleFoundationModels`, `androidAiEdge`, `httpCompletion`) inside `GenuiExpressLocalModels`. - Updated the local models registration logic to use these public constants. - Refactored model instantiation in `chat_session.dart` (express_chat example) to leverage the new type-safe model constants. - Updated imports in `compiler_test.dart` to directly reference compiler internals package-relatively.
- Exclude all `*_web.dart` files (e.g., `genui_express_web.dart`, `chrome_plugin_web.dart`) in `test_and_fix.dart` from being imported in the autogenerated `ephemeral_coverage_all_test.dart` file. - This prevents compiler crashes on native VM test environments caused by missing `dart:ui_web` and `dart:js_interop` libraries. - Updated `coverage_policy.yaml` to globally exclude `**/*_web.dart` and set explicit policies for the new packages (genui_express threshold of 60% and disabled express_chat). - Updated `coverage_baseline.yaml` high-water marks.
…example - Enabled coverage verification for `examples/express_chat` in `coverage_policy.yaml` with a threshold of 30.0%. - Updated `coverage_baseline.yaml` to record its high-water mark (35.8%).
…ample - Enabled coverage verification for `examples/simple_chat` in `coverage_policy.yaml` with a threshold of 30.0%. - Updated `coverage_baseline.yaml` to record its high-water mark (37.3%). - Note: examples/verdure/client remains disabled since it does not contain a 'test/' directory.
5b39eab to
776baf1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This change introduces the new
genui_expressFlutter plugin package alongside a new demonstration application,express_chat, to provide offline local generative UI compilation and on-device LLM execution in the monorepo.Key changes
New package:
genui_expressIntroduced
/packages/genui_expressas a standalone, shareable Flutter plugin package providing offline generative UI capabilities:token.dart.parser.dartto process positional expressions.ExpressCompilerandCatalogSchemaHelperto dynamically map catalog component arguments to layout definitions and compile them into valid standard A2UI JSON specifications.ExpressPromptBuilder(conforming to GenUI'sPromptBuildercontract) to format compact positional component signatures optimized for local models.on_device_plugins.dartusing the Genkit framework: Apple Intelligencelocal/apple-foundation-models(macOS/iOS), Google AI Edge SDKlocal/android-ai-edge(Android), and Ollama completionslocal/http-completion.ExpressLocalTransport(conforming to GenUI'sTransportcontract) to manage conversation session history, intercept LLM output streams, isolate layout blocks, trigger compiler updates, and emit A2UI specifications. Added resilient support to parse standard JSON maps and arrays.New example app:
express_chatIntroduced
/examples/express_chatas a rich demonstration application showing offline generative UI in action:chat_session.dartandmain.dartto coordinate local chat sessions and handle progressive text bubbles and surface rendering.genkit_chrome: ^0.0.8as an application dependency. Implemented compile-safe conditional import stubs (chrome_plugin_stub.dartandchrome_plugin_web.dart) to register the Chrome AI Gemini Nano plugin when running in the browser while preventing compiler errors on native mobile/desktop platforms.chrome/gemini-nano) when running on Web, and to your local completions server (local/http-completionon port8080running Gemma 4) when running natively on macOS.Native compilation configurations
Podfileto support SwiftLanguageModelingmodules.#if canImport(LanguageModeling)compiler blocks to allow compilation inside sandboxed developer containers while loading the native Neural Engine session at runtime.Workspace maintenance
pubspec.yamlto include bothpackages/genui_expressandpackages/genui_express/exampleinside the monorepo workspace member list./tool/test_and_fix/pubspec.yamlto requireanalyzer: ">=10.0.0 <14.0.0", resolving package resolution conflicts across the monorepo.Verification
All changes have been verified using static analysis, compiler suites, and integration tests:
packages/genui_express. All tests pass.express_chatapp boots successfully.